package me.tuyou;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;

public class MyTestBean {

    private String name = "tuyou";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
        reader.loadBeanDefinitions(new ClassPathResource("beanFactoryTest.xml"));

        MyTestBean bean = beanFactory.getBean(MyTestBean.class);
        System.out.println(bean.getName());

        bean.setName("yangrui");
        System.out.println(bean.getName());

        BeanDefinition myTestBean = beanFactory.getBeanDefinition("myTestBean");
        System.out.println(myTestBean.isSingleton());
    }
}
